﻿package com.mod.page  {
	
    import com.calefk.core.Page;
	import com.mod.Global;
    import com.mod.ModProject;
    import com.mod.PMGame;
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
	
	public class MenuPage extends Page {
		
		public function MenuPage(canvas:MovieClip, nameClip:String = null,
				x:Number = 0, y:Number = 0) {
			super(canvas, nameClip, x, y);
			clip.endEndInvoking = addListeners;
			clip.play();
			Global.stopAllSounds();
			//clip.btnPlay.addEventListener(MouseEvent.CLICK , onPlay , false , 0 , true);
            Global.playSound("bgm_menu_screen", int.MAX_VALUE);
		}
		
		public function addListeners():void 
		{
			clip.btnPlay.addEventListener(MouseEvent.CLICK , onPlay , false , 0 , true);
			clip.btnStaff.addEventListener(MouseEvent.CLICK, onStaff, false , 0 , true)
			clip.btnHelp.addEventListener(MouseEvent.CLICK, onHelp, false, 0, true);
		}
		
		private function onHelp(e:MouseEvent):void 
		{
			Global.stopAllSounds();
			ModProject.getPM().onTransition(600, 300 , PMGame.PAGE_HELP , null , null , 0xffffff , Global.SW , Global.SH); 
		}
		
		private function onStaff(e:MouseEvent):void 
		{
			Global.stopAllSounds();
			ModProject.getPM().onTransition(600, 300 , PMGame.PAGE_CREDITS , null , null , 0xffffff , Global.SW , Global.SH); 
		}

		private function onPlay(e:MouseEvent):void {
            // go to page game
			Global.stopAllSounds();
            ModProject.getPM().onTransition(600, 300 , PMGame.PAGE_GAME , null , "initPage" , 0xffffff , Global.SW , Global.SH); 
		}
		
		override public function clean():void {
			clip.btnPlay.removeEventListener(MouseEvent.CLICK , onPlay);
			clip.btnStaff.removeEventListener(MouseEvent.CLICK, onStaff);
			super.clean();
			
		}
	}

}